﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage/MasterPage.Master" AutoEventWireup="true" CodeBehind="BGM_Expense.aspx.cs" Inherits="KPIS.GERP.GBMS.APP_UI.Form.BGM_Expense" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<%@ Register src="../Controls/Combo/SourceCombo.ascx" tagname="SourceCombo" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None">
    </telerik:RadAjaxLoadingPanel>

    <telerik:RadAjaxManager runat="server" ID="RadManager1" 
        DefaultLoadingPanelID="RadAjaxLoadingPanel1" 
        OnAjaxRequest="RadManager1_AjaxRequest" >
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="pnlControl">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="pnlControl" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="PanelGrid" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="panelList" LoadingPanelID="RadAjaxLoadingPanel1"/>                  
                    <telerik:AjaxUpdatedControl ControlID="PanelTree" LoadingPanelID="RadAjaxLoadingPanel1"/>                                        
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="panelGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelGrid" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="panelList" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="pnlControl" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="tView" LoadingPanelID="RadAjaxLoadingPanel1"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="tView">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelGrid" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="panelList" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="pnlControl" LoadingPanelID="RadAjaxLoadingPanel1"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function StopPropagation(e)
        {
            if(!e)
            {
                e = window.event;
            }

            e.cancelBubble = true;
        }
    
        var cancelDropDownClosing = false;
        function StopPropagation(e) {
            e.cancelBubble = true;
            if (e.stopPropagation) {
                e.stopPropagation();
            }
        }

        function OnClientDropDownClosingHandler(sender, e) {
            e.set_cancel(cancelDropDownClosing);
        }
    
    </script>
    </telerik:RadCodeBlock>
 
    <div class="defaultFont"> 
        
        <asp:Label ID="hdSeq" Visible="true" runat="server" Text="" ></asp:Label>
        <asp:Label ID="hdSeqParent" Visible="false" runat="server" Text="" ></asp:Label>
        <asp:Label ID="hdExpGrpSeq" Visible="false" runat="server" Text="" ></asp:Label>
        <asp:Label ID="hdLevel" Visible="true" runat="server" Text="" ></asp:Label>
        
        <div class="DivControl" style="padding-left: 10px; padding-right: 10px; color: #FFFFFF; font-weight: bold; font-size: large;">
            ข้อมูลหมวด/รายการ/ค่าใช้จ่าย
        </div>
         
        <table width="1000px" cellpadding="0" cellspacing="0" >
            <tr>
                <td rowspan="2" valign="top" width="280px" style="border-width: 1px; 
                    border-right-style: solid; border-color: #627AAD;"> 
                    <div class="DivInfo" style="font-weight: bold; ">
                        <table cellpadding="1" cellspacing="0">
                            <tr>
                                <td>
                                    ผังค่าใช้จ่าย
                                </td>
                            </tr>
                        </table>
                    </div>
                    <asp:Panel ID="PanelTree" runat="server">
                        <br />
                        <%--Height='<%# Unit.Pixel(new SsMng().GetUssI(SsMng.SsUserType.Height) - 250) %>'--%>
                        <telerik:RadTreeView ID="tView" 
                            runat="server" 
                            DataFieldID="bgm_exp_seq" 
                            DataValueField="bgm_exp_seq" 
                            DataFieldParentID="upper_bgm_exp_seq"
                            DataTextField="bgm_exp_name" 
                            OnNodeClick="tView_NodeClick"
                            
                            Width="280px">
                            <CollapseAnimation Duration="0" Type="None" />
                            <ExpandAnimation Duration="0" Type="None" />
                            <DataBindings>
                                <telerik:RadTreeNodeBinding />
                            </DataBindings>
                        </telerik:RadTreeView>       
                        
                    </asp:Panel>
                </td> 
                <td valign="top"  style="margin-left: 10px;">
                    <asp:Panel ID="pnlControl" runat="server">
                        <div class="DivInfo">
                            <asp:LinkButton ID="AddNew" runat="server" CssClass="ControlLinkButton" OnClick="AddNew_Click"><img alt="" src="../Image/Grid/AddRecord.gif" />&nbsp;&nbsp;เพิ่มข้อมูลใหม่</asp:LinkButton>
                            <asp:LinkButton ID="Delete" runat="server" CssClass="ControlLinkButton" OnClientClick="javascript:return confirm('ยืนยันการลบข้อมูลที่เลือก')" OnClick="Delete_Click"><img alt="" src="../Image/Grid/Delete.gif" />&nbsp;&nbsp;ลบข้อมูล</asp:LinkButton>
                            <asp:LinkButton ID="Save_AddNew" runat="server" CssClass="ControlLinkButton" Visible="false" onclick="Save_AddNew_Click" ValidationGroup="1"><img alt="" src="../Image/Grid/Cmd_Save.gif" />&nbsp;&nbsp;บันทึกข้อมูล</asp:LinkButton>
                            <asp:LinkButton ID="Save_Edit" runat="server" CssClass="ControlLinkButton" Visible="false" onclick="Save_Edit_Click" ValidationGroup="1"><img alt="" src="../Image/Grid/Cmd_Save.gif" />&nbsp;&nbsp;บันทึกข้อมูล</asp:LinkButton>
                            <asp:LinkButton ID="Cancel" runat="server" CssClass="ControlLinkButton" Visible="false" onclick="Cancel_Click"><img alt="" src="../Image/Grid/Cancel.gif" />&nbsp;&nbsp;ยกเลิกแก้ไข</asp:LinkButton>
                        </div>
                    </asp:Panel>
                </td>
              </tr>
              <tr valign="top"  >
                 <td  style="margin-left: 10px;">
                    <asp:Panel runat="server" ID="panelList" Visible="false">
                        <br />
                        <div class="header-grid">
                            <div class="defaultFont">
                                <asp:Label ID="labelNodeTypeInfo1" runat="server"></asp:Label>
                                <%--<asp:TextBox ID="labelNodeTypeInfo" runat="server" Width="100%" 
                                    BorderStyle="None" BackColor="Transparent"  ForeColor="#567DB0" 
                                    Font-Bold="True" ReadOnly="True" Font-Names="Rod" ></asp:TextBox>--%>
                            </div>
                        </div>
                        <asp:Panel ID="PanelInfo" runat="server">
                            <ul class="formList" id="Ul1" >
                                <li>
                                    <table>
                                        <tr>
                                            <td width = "150px">
                                                รหัส :
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtCode" runat="server" Width="150px" ValidationGroup="1"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                    ControlToValidate="txtCode" ErrorMessage="*" SetFocusOnError="True" 
                                                    ValidationGroup="1"></asp:RequiredFieldValidator>
                                                <input id="hBgmExpGrpSeq" runat="server" type="hidden" />
                                            </td>
                                        </tr>
                                    </table>
                                </li>
                                <li>
                                    <table>
                                        <tr>
                                            <td width = "150px">
                                                รหัสในระบบ GFMIS :
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtGFMISCode" runat="server" Width="150px" ValidationGroup="1"></asp:TextBox>
                                            
                                                <input id="hGFMISCode" runat="server" type="hidden" />
                                            </td>
                                        </tr>
                                    </table>
                                </li>
                                <li>
                                    <table>
                                        <tr>
                                            <td width = "150px">
                                                ชื่อค่าใช้จ่าย :
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtName" runat="server" Width="300px" ValidationGroup="1"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                                    ControlToValidate="txtName" ErrorMessage="*" SetFocusOnError="True" 
                                                    ValidationGroup="1">
                                                </asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                    </table>
                                </li>               
                                <li>
                                    <table>
                                        <tr>
                                            <td width = "150px" valign="top">
                                                คำอธิบาย :
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtDescr" runat="server" TextMode="MultiLine" Height="100" Width="300px"></asp:TextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </li>
                                <asp:Panel ID="pnExpGrpReal" runat="server">
                                    <li>
                                        <table>
                                            <tr>
                                                <td width="150px" valign="top">
                                                    ลักษณะงบรายจ่าย :
                                                </td>
                                                <td>
                                                    <input runat="server" id="lbBgmExpGrpSeqReal" type="hidden" />
                                                    <telerik:RadComboBox runat="server" 
                                                        ID="ddlBgmExpGrpSeqReal" 
                                                        DataTextField="text" 
                                                        DataValueField="value" 
                                                        Width="200px" AutoPostBack="True" 
                                                        OnSelectedIndexChanged="ddlBgmExpGrpSeqReal_SelectedIndexChanged">
                                                    </telerik:RadComboBox>
                                                </td>
                                            </tr>
                                        </table>
                                    </li>
                                </asp:Panel>
                                <asp:Panel ID="pnInvCheck" runat="server">
                                    <li>
                                        <asp:CheckBox ID="chkInv" runat="server" Text="เป็นค่าใช้จ่ายในการซื้อพัสดุ" 
                                            AutoPostBack="true" OnCheckedChanged="chkInv_CheckedChanged" />
                                        <asp:Panel ID="pnInv" runat="server">
                                            <table>
                                                <tr>
                                                    <td width = "150px" valign="top">
                                                        ประเภทพัสดุ :
                                                    </td>
                                                    <td>
                                                        <input runat="server" id="lbResourceGrpSeq" type="hidden" />
                                                        <telerik:RadComboBox runat="server" Filter="Contains"
                                                            ID="ddlResourceGrp" 
                                                            DataTextField="Name" 
                                                            DataValueField="Id" 
                                                            Width="400px" ZIndex="8000">
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                            </table>
                                        </asp:Panel>
                                    </li>
                                </asp:Panel>
                                <li>
                                    <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="RadGridBgmExpenseSource" runat="server" AllowFilteringByColumn="false"
                                        AllowMultiRowSelection="True" AllowPaging="false" AllowSorting="True"
                                        AutoGenerateColumns="False" ShowStatusBar="false">
                                        <MasterTableView AllowMultiColumnSorting="true" Width="100%">
                                            <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                                            <Columns>
                                                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" ItemStyle-Width="30px"
                                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                                                </telerik:GridClientSelectColumn>
                                                <telerik:GridBoundColumn UniqueName="value" DataField="value" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="bgm_exp_source_seq" DataField="bgm_exp_source_seq" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                                    CurrentFilterFunction="Contains" DataField="text" 
                                                    FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="80px"
                                                    HeaderText="แหล่งเงินที่ใช้งานได้" ShowFilterIcon="false" ItemStyle-HorizontalAlign="Left"
                                                    UniqueName="text">
                                                </telerik:GridBoundColumn>
                                            </Columns>
                                        </MasterTableView>
                                        <ClientSettings EnableRowHoverStyle="false">
                                            <Selecting AllowRowSelect="True" />
                                            <ClientEvents />
                                        </ClientSettings>
                                    </telerik:RadGrid>
                                </li>
                            </ul>
                        </asp:Panel>
                    </asp:Panel>
                    <asp:Panel ID="panelGrid" runat="server" Visible="true">
                        <br />
                        <div class="header-grid" style="margin-bottom: 4px;">
                            <div class="defaultFont">
                                <asp:Label ID="labelNodeTypeInfo2" runat="server" Text="ข้อมูลค่าใช้จ่าย"></asp:Label>
                            </div>
                        </div> 
                        <%--Height='<%# Unit.Pixel(new SsMng().GetUssI(SsMng.SsUserType.Height) - 250) %>'--%>
                        <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="Grid" runat="server" AllowFilteringByColumn="true"
                            AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True"
                            AutoGenerateColumns="False" EnableAJAX="True" OnItemCommand="Grid_ItemCommand"
                            GridLines="None" PageSize="10" ShowStatusBar="false"
                            >
                            <MasterTableView AllowMultiColumnSorting="true" DataKeyNames="Sequence" ClientDataKeyNames="Sequence"
                                Width="100%">
                                <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                                <Columns>
                                    <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" ItemStyle-Width="30px"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                                        </telerik:GridClientSelectColumn>
                                    <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                        CurrentFilterFunction="Contains" DataField="Code" 
                                        FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="80px"
                                        HeaderText="รหัส" ShowFilterIcon="false" ItemStyle-HorizontalAlign="Left"
                                        UniqueName="Code">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                        CurrentFilterFunction="Contains" DataField="gfmis_code" 
                                        FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="80px"
                                        HeaderText="รหัส GFMIS" ShowFilterIcon="false" ItemStyle-HorizontalAlign="Left"
                                        UniqueName="gfmis_code">
                                    </telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn AutoPostBackOnFilter="true" 
                                        CurrentFilterFunction="Contains" DataField="Name" FilterControlWidth="100%" 
                                        HeaderStyle-HorizontalAlign="Center" Visible="false"
                                        ShowFilterIcon="false">
                                        <ItemTemplate>
                                            <asp:Label ID="targetSequence" runat="server" Text='<%# Eval("Sequence") %>'></asp:Label>
                                        </ItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" />
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn AutoPostBackOnFilter="true" 
                                        CurrentFilterFunction="Contains" DataField="Name" FilterControlWidth="100%" 
                                        HeaderStyle-HorizontalAlign="Center" HeaderText="ชื่อค่าใช้จ่าย" 
                                        ShowFilterIcon="false"  UniqueName="Name">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="targetControl" runat="server" CommandName="TargetClick"
                                                Text='<%# Eval("Name") %>'></asp:LinkButton>
                                        </ItemTemplate>
                                        <HeaderStyle HorizontalAlign="Center" />
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                        CurrentFilterFunction="Contains" DataField="Description" 
                                        FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                        HeaderText="คำอธิบาย" ShowFilterIcon="false" UniqueName="Description" Visible="false">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings EnableRowHoverStyle="true" >
                                <Selecting AllowRowSelect="True" />
                                <ClientEvents />
                            </ClientSettings>
                        </telerik:RadGrid>
                    </asp:Panel>
                </td>
            </>
        </table>
    </div>
</asp:Content>
<asp:Content ID="Content2" runat="server" contentplaceholderid="head">
    <link rel="StyleSheet" href="../../Styles/StyleSheet.css" type="text/css" />
</asp:Content>

